package com.qf.dao;

import com.qf.entity.EmpManager;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @author zdl
 * @date 2025/1/16
 */
public class EmpManagerDao {
    public EmpManager selectEmpManagerByUsernameAndPassword(String username,String password){
        try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test1?useSSL=false", "root", "123456");
            QueryRunner qr = new QueryRunner();
            String sql = "select * from emp_manager where username = ? and password = ?";
            EmpManager query = qr.query(conn, sql, new BeanHandler<>(EmpManager.class), username, password);
            return query;
        } catch (ClassNotFoundException | SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
